
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},

  },

  
  onLoad: function (options) {
    this.getUserInfo();
  },

  /* 获取个人信息 */
  getUserInfo: function () {
    let userInfo = wx.getStorageSync('userInfo');
    let userId = wx.getStorageSync('userId');
    console.log(userInfo)
    this.setData({
      userInfo: userInfo
    });
    this.setData({
      userId: userId
    });
  },

  navigateTo(e) {
    console.log(e)
    const url = e.currentTarget.dataset.url;
    console.log(url)
    if (e.currentTarget.dataset.urlType) {
      wx.navigateTo({
        url: 'user-info/user-info'
      });
    } else {
      if (url === undefined) {
        wx.makePhoneCall({
          phoneNumber: e.currentTarget.dataset.tip
        });
      } else {
        wx.navigateTo({
          url
        });
      }
    }
  },

  /* 跳转待付款 */
  navigatedfk() {
    wx.navigateTo({
      url: '../orders/orders?t=unpaid',
    })
  },
  /* 跳转待发货 */
  navigatedfh() {
    wx.navigateTo({
      url: '../orders/orders?t=undelivered',
    })
  },
  /* 跳转待收货 */
  navigatedsh() {
    wx.navigateTo({
      url: '../orders/orders?t=unreceived',
    })
  },
  // /* 跳转待评价 */
  // navigatedpj() {
  //   wx.navigateTo({
  //     url: '../orders/orders?t=unevaluation',
  //   })
  // },
  /* 跳转全部订单 */
  navigateqbdd() {
    wx.navigateTo({
      url: '../orders/orders?t=all',
    })
  },
  /* 跳转地址管理 */
  navigateAddress(){
    wx.navigateTo({
      url:'../addresses/addresses',
    })
  },

    // select_address: function (e) {
  //   if (this.data.choosed_address) {
  //     // 如果已经选择了地址，则变成可编辑框
  //     return
  //   }

  //   wx.chooseAddress({
  //     success: res => {
  //       this.data.address = `${res.cityName}${res.countyName}${res.detailInfo}`

  //       this.setData({
  //         address: this.data.address,
  //         choosed_address: true,
  //         // 如果用户收货地址里有手机号和姓名，使用选择的内容覆盖当前内容
  //         name: res.userName,
  //         tel: res.telNumber,
  //       })
  //     },

  //     fail: res => {
  //       this.setData({
  //         choosed_address: true
  //       })
  //       // TODO
  //       // 自动从后台拉取其已有的收货地址
  //     },
  //   })
  // },
})